﻿<cfsilent>
	<cfscript>
	
		propAdvice = getProperty("serviceFactory").getBean("cetPropertyAdvice");
		jsonAdvice = getProperty("serviceFactory").getBean("jsonAdvice");
	
		response = structNew();
		
		transaction {
			
			cetId = event.getArg("EX");
			
			/* 加载要更新对象 */
			sql = "SELECT exam_prop FROM t_cet WHERE exam_id = :cetId ";
			
			queryObj = new Query( datasource=application.dnsMaster );
			queryObj.addParam( name="cetId", value=cetId, cfsqltype="cf_sql_char" );

			rs_entity = queryObj.execute( sql=sql ).getResult();
			
			examProp = rs_entity.exam_prop;
			
			propAdvice.parseProperty( examProp );
			
			switch ( event.getArg('prop' )) {
				
				case "Running":
					/* 该轮次是否可用 */
					if ( yesNoFormat(event.getArg('status')) ) {
						propAdvice.setRunning( true );
					}
					else {
						propAdvice.setRunning( false );
					}
					
			}
			
			examProp = propAdvice.stringProperty();
			
			/* 更新考试科目设置 */
			sql = "UPDATE t_cet 
					SET exam_prop = :examProp 
					WHERE 
						exam_id = :cetId ";
			
			queryObj = new Query( datasource=application.dnsMaster );
			queryObj.addParam( name="cetId", value=cetId, cfsqltype="cf_sql_char" );
			queryObj.addParam( name="examProp", value=examProp, cfsqltype="cf_sql_varchar" );

			queryObj.execute( sql=sql );

			structInsert(response, "Running", propAdvice.getRunning());
			
		}
		
	</cfscript>
</cfsilent><cfoutput>#jsonAdvice.encode(data:response, stringNumbers:true)#</cfoutput>